/*
 * @Author: szx
 * @Date: 2022-03-07 13:14:32
 * @LastEditTime: 2022-03-07 13:20:03
 * @Description:
 * @FilePath: \leetcode\500-599\504\504.js
 */
/**
 * @param {number} num
 * @return {string}
 */
var convertToBase7 = function (num) {
    if (num == 0) return '0';
    const arr = [];
    let flag = 1;
    if (num < 0) {
        num = -num;
        flag = -1;
    }

    while (num > 0) {
        arr.push(num % 7);
        num = Math.floor(num / 7);
    }
    if (flag < 0) arr.push('-');
    return arr.reverse().join('');
};
console.log(convertToBase7(99));
